/*eslint-env node*/
"use strict";
(function () {
  let WebSocketServer = require('ws').Server,
  wss = new WebSocketServer({ port: 8188 });

  wss.on('connection', function (ws) {
    console.log('客户端已连接');
    ws.on('message', function (data, isBinary) {
      wss.clients.forEach(function each(client) {
        if (client !== ws && client.readyState === WebSocket.OPEN) {
          client.send(data, { binary: isBinary });
        }
      });
      console.log(data.length);
    });
  });
  console.log('创建ws服务成功...');
})();
